package xdu.ble.common.exception;

import xdu.ble.common.enums.ExceptionCode;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 向前端返回信息封装
 *
 */
public class ExceptionResponse {
    /**
     * 响应码
     */
    private int statusCode;

    /**
     * 返回信息
     */
    private String statusMsg;

    /**
     * 获取当前时间  格式：年月日时分秒     如2021-01-02 12:13:44
     * @return  返回20210102121344
     */
    private String time;

    private static final SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public ExceptionResponse(ExceptionCode exceptionCode) {
        this.statusCode = exceptionCode.getCode();
        this.statusMsg = exceptionCode.getReason();
        this.time = SDF.format(new Date(System.currentTimeMillis()));
    }


    public int getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(int statusCode) {
        this.statusCode = statusCode;
    }

    public String getStatusMsg() {
        return statusMsg;
    }

    public void setStatusMsg(String statusMsg) {
        this.statusMsg = statusMsg;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }
}
